package com.tlvip.arithmetic.ch02;

/**
 * <p>description：</p>
 * <p>copyright： copyright(C)2016-2099</p>
 * <p>Life is short,we need passion</p>
 * <p>Summary： </p>
 * <p>instructions： </p>
 * Date 1/23/21</p>
 * Author mac
 *
 * @version 1.0
 */
public class StackMemTest {
    String str1 = "abc";
    String str2 = "abc";

    private void judge1() {
        System.out.println(str1 == str2);
    }

    public static void main(String[] args) {
        StackMemTest stackMemTest = new StackMemTest();
        stackMemTest.judge1();
        stackMemTest.judge2();
        stackMemTest.judge3();
        stackMemTest.judge4();
    }

    String str3 = "abc";
    String str4 = "abc";

    {
        str3 = "bcd";
    }

    private void judge2() {
        System.out.println(str3 == str4);
    }

    String str5 = new String("abc"); // 堆内存
    String str6 = "abc"; // 栈内存

    private void judge3() {
        System.out.println(str5 == str6);
    }

    String s1 = "ja";
    String s2 = "va";
    String s3 = "java";
    String s4 = s1 + s2; // +号被重载了，其实调用了StringBuild，会new对象

    private void judge4() {
        System.out.println(s3 == s4);
        System.out.println(s3.equals(s4));
    }

}
